﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DTgame_EndTrigger : MonoBehaviour
{
    public int enemyEnterNub = 0;
    public Transform createEnemyPoint;
    public float respawnTime = 3f;
    public GameObject[] wayPointList;
    public GameObject[] enemyList;
    public int ememyCreateIndex = 0;
    float timer;
    // Start is called before the first frame update
    void Start()
    {
        timer = respawnTime;
    }

    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;

        if(timer<=0)
        {
            
            timer = respawnTime;
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if(other.tag.Equals("Enemy"))
        {
            enemyEnterNub++;
            Destroy(other.gameObject);
        }
    }

    private void createNoLoop()
    {
        if (ememyCreateIndex < enemyList.Length)
        {
            var enemy = Instantiate(enemyList[ememyCreateIndex], transform.position, transform.rotation);
            int rand=(int)Random.Range(0, wayPointList.Length+1);
            enemy.GetComponent<EnemyMove>().wayPointList = wayPointList[rand].transform;
        }
    }
}
